<!DOCTYPE html>
<html class="x-admin-sm">

<head>
  <meta charset="UTF-8">
  <title>设备/终端扫描入库</title>
  <meta name="设renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <link rel="stylesheet" href="../../css/font.css">
  <link rel="stylesheet" href="../../css/xadmin.css">
  <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>

  <script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../../js/app.js" type="text/javascript" charset="utf-8"></script>
  <style type="text/css">
    .form-position {
      margin: 0.85rem;
      padding-top: 8px;
      background-color: white;
    }
  </style>
</head>

<body>
  <div class="x-nav">
    <span class="layui-breadcrumb">
      <a href="">首页</a>
      <a href="">演示</a>
      <a>
        <cite>导航元素</cite></a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
      onclick="location.reload()" title="刷新">
      <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
  </div>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body ">
            <div class="layui-collapse" lay-filter="test">
              <div class="layui-colla-item">
                <h2 class="layui-colla-title">先进行选择再扫码入库<i class="layui-icon layui-colla-icon"></i></h2>
                <div class="layui-colla-content layui-show" style="display: flex;">
                  <div>

                    <form class="layui-form form-position" style="margin: 0;" action="" lay-filter="Form" id="Form"
                      name="Form">
                      <div class="layui-input-inline layui-show-xs-block">
                        <select name="category" id="category" lay-filter="category">
                          <option value=""></option>
                        </select>
                      </div>
                      <div class="layui-input-inline layui-show-xs-block">
                        <select name="typical" id="typical" lay-filter="typical">

                        </select>
                      </div>
                      <div class="layui-input-inline layui-show-xs-block" style="">
                        <select name="brand" id="brand" lay-filter="brand">

                        </select>
                      </div>

                      <div class="layui-input-inline layui-show-xs-block">
                        <select name="model" id="model" lay-filter="model">

                        </select>
                      </div>
                      <div class="layui-input-inline layui-show-xs-block">
                        <select name="repository" id="repository" lay-filter="repository">

                        </select>
                      </div>
                      <div class="layui-input-inline layui-show-xs-block">
                        <input type="text" name="serial_number" placeholder="点击此处后进行扫码" autocomplete="off"
                          class="layui-input layui-hide" id="serial_number">
                      </div>

                    </form>
                  </div>
                  <div class="layui-inline layui-show-xs-block" style="margin-top: 7.2px;margin-left: 4px;">
                    <button class="layui-btn" onclick="InstorageInfo_Ajax()"><i
                        class="layui-icon">&#x1005;</i>确认入库</button>
                  </div>
                  <div class="layui-input-inline" style="margin: 8px 8px 8px 4px;">

                  </div>
                </div>
              </div>
            </div>
            <div class="layui-card-body " style="padding: 10px 0px;">
              <table class="layui-table layui-form">
                <thead id="table-thd" class="layui-hide">
                  <tr>
                    <th>串号</th>
                    <th>种类</th>
                    <th>类别</th>
                    <th>品牌</th>
                    <th>型号</th>
                    <th style="text-align: center;">操作</th>
                </thead>
                <tbody id="table-tby">
                  <tr id="Tr">

                  </tr>
                </tbody>
              </table>
            </div>
            <!-- <div class="layui-card-body" style="display: flex;justify-content: center;">
              <div id="demo7">
                <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-10"><span
                    class="layui-laypage-count">共
                    100 条</span><a href="javascript:;" class="layui-laypage-prev layui-disabled"
                    data-page="0">上一页</a><span class="layui-laypage-curr"><em
                      class="layui-laypage-em"></em><em>1</em></span><a href="javascript:;" data-page="2">2</a><a
                    href="javascript:;" data-page="3">3</a><a href="javascript:;" data-page="4">4</a><a
                    href="javascript:;" data-page="5">5</a><span class="layui-laypage-spr">…</span><a
                    href="javascript:;" class="layui-laypage-last" title="尾页" data-page="10">10</a><a
                    href="javascript:;" class="layui-laypage-next" data-page="2">下一页</a><span
                    class="layui-laypage-limits"><select lay-ignore="">
                      <option value="10" selected="">10 条/页</option>
                      <option value="20">20 条/页</option>
                      <option value="30">30 条/页</option>
                      <option value="40">40 条/页</option>
                      <option value="50">50 条/页</option>
                    </select></span><a href="javascript:;" data-page="1" class="layui-laypage-refresh"><i
                      class="layui-icon layui-icon-refresh"></i></a><span class="layui-laypage-skip">到第<input
                      type="text" min="1" value="1" class="layui-input">页<button type="button"
                      class="layui-laypage-btn">确定</button>
                  </span>
                </div>
              </div>
            </div> -->
          </div>
        </div>
      </div>
    </div>
  </div>
  <script src="Select.js" type="text/javascript" charset="utf-8"></script>
  <script src="Scan.js" type="text/javascript" charset="utf-8"></script>
  <script>
    //注意：折叠面板 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
      var element = layui.element;

    });
  </script>
  <script type="text/javascript">
    // 提交扫码后的数据
    function InstorageInfo_Ajax() {
      var type = JSON.parse(localStorage.getItem("Conditions_category"));
      var type_num = type.category.split(",")
      var typical = JSON.parse(localStorage.getItem("Conditions_typical"))
      var brand = JSON.parse(localStorage.getItem("Conditions_brand"))
      var model = JSON.parse(localStorage.getItem("Conditions_model"))
      var serial_number = localStorage.getItem("serial_number_arr")
      var materialTypicalId = localStorage.getItem("materialTypicalId")
      var respositoryId = localStorage.getItem("repositoryId");
      var operator = app.getUserGlobalInfo();
      var operator_Id = operator.userId;

      var arr = [];
      arr.push(serial_number);
      // console.log(arr);

      if (!serial_number) {
        layer.msg('请先扫码后再执行入库操作！')
      } else {
        var new_arr = arr[0].split(",");
        // console.log(new_arr);
        layer.confirm('确认要将这些数据导入数据库吗？', {
          title: '提示信息',
          icon: 3,
          btn: ['确认', '取消'],
          yes: function (index) {
            $.ajax({
              url: app.ServerUrl + 'v1/material/inStorageMaterial/' + type_num[1],
              type: "post",
              contentType: "application/json;charset=UTF-8",
              dataType: "json",
              async: true,

              data: JSON.stringify({
                "count": "",
                "imei": new_arr,
                "materialTypicalId": materialTypicalId,
                "name": "",
                "operator": operator_Id,
                "sourceRepositoryId": "",
                "stuffId": "",
                "targetRepositoryId": respositoryId
              }),
              success: function (data) {
                // console.log(data)
                layer.open({
                  content: '入库成功！',
                  btnAlign: 'c',
                  anim: 5,
                  icon: 6,
                  yes: function () {
                    window.location.reload();
                  }
                });
              },
              error: function (e) {
                layer.open({
                  content: '入库失败！',
                  btnAlign: 'c',
                  anim: 5,
                  icon: 5,
                  cancel: function () {}
                });
              }

            })
            layer.close(index);
          },
          cancel: function (index) {
            layer.close(index);
          }
        })
      }
    }
  </script>
  <script>
    var _hmt = _hmt || [];
    (function () {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>
  <script type="text/javascript" src="../../js/xadmin.js"></script>
</body>

</html>